package cn.itcast.web.cookie;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/*
 * cookie细节操作:
 * 1.能不能一次发送多个cookie到客户单浏览器？要怎么发送？
 * 可以创建多个Cookie对象，使用response调用多次addCookie方法发送cookie即可。
 *
 * */
@WebServlet("/cookieservletDemo3")
public class CookieServletDemo3 extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        //1.创建Cookie对象
        Cookie cookie=new Cookie("msg","hello");
        Cookie cookie1=new Cookie("msg1","hello1");
        //2.发送Cookie到浏览器
        response.addCookie(cookie);
        response.addCookie(cookie1);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
